package pl.edu.agh.gameserv.server.test;

import static org.junit.Assert.assertEquals;
import org.junit.Test;

import pl.edu.agh.gameserv.server.test.helper.User;

public class ExitDuringGameIT {
	ServerImplService service;

	@Test
	public void exitDuringGame() throws Exception {
			service = new ServerImplService();
			ServerImpl server = service.getServerImplPort();

			User user1 = new User("Bolek", server);
			user1.joinGame();

			User user2 = new User("Lolek", server);
			user2.joinGame();
			
			user1.makeMove("00");
			user2.makeMove("20");
			user1.exit();
			
			assertEquals(GameStatus.FINISHED, user1.getState());
			user2.makeMove("11");
			assertEquals(GameStatus.FINISHED, user2.getState());
			assertEquals("Jeden z graczy opuścił grę.", user1.getScore());
			assertEquals("Jeden z graczy opuścił grę.", user2.getScore());

	}

}